//
//  SetPassViewController.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/11/17.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "SetPassViewController.h"
#import "SetPassView.h"
#import "PerfectViewController.h"

@interface SetPassViewController ()

@property(nonatomic,weak)SetPassView *setPassView;

@end

@implementation SetPassViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];

    self.view.backgroundColor = CSWhiteColor;
    
    SetPassView *setPassView = [[SetPassView alloc] initWithFrame:self.view.frame];
    
    [setPassView.nextBtn addTarget:self action:@selector(nextBtnClick)forControlEvents:UIControlEventTouchUpInside];
    //密码明文暗文切换
    [setPassView.lookBtn addTarget:self action:@selector(passwordChange:)forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:setPassView];
    
    self.setPassView = setPassView;
}

#pragma mark 密码切换
-(void)passwordChange:(UIButton *)btn{
    
    btn.selected = !btn.selected;
    
    self.setPassView.passWordTF.secureTextEntry = !self.setPassView.passWordTF.secureTextEntry;
    
    NSString* text = self.setPassView.passWordTF.text;
    
    self.setPassView.passWordTF.text = @" ";
    
    self.setPassView.passWordTF.text = text;
}

#pragma mark 下一步
-(void)nextBtnClick{
    
    NSString *passWord = self.setPassView.passWordTF.text;
    
    if (!passWord || passWord.length == 0) {
        
        [MBProgressHUD showText:@"密码不能为空" toview:self.view];
        
//        return;
    }
        
//    UserAccount *userAccount = [UserAccount account];
//
//    userAccount.userPassword = passWord;
//
//    [UserAccount saveAccount:userAccount];
    
    PerfectViewController *perfectVC = [[PerfectViewController alloc] init];
    
    [self.navigationController pushViewController:perfectVC animated:YES];
}
@end
